<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:fn="http://java.sun.com/jsp/jstl/functions">
    <style type="text/css">
        .tableStyle{
            margin:0px 0px 5px 0px;
        }
        .gridStyle{
            margin:10px 10px 10px 0px;
        } 
        .top{
            vertical-align: top;
            text-align:left;
        }
    </style>
    <h:form id="finProjForm">
        <rich:panel header="财政项目" id="finPanel" styleClass="content-hight">            
            <rich:toolbar id="tolbar">
                <rich:toolbarGroup>
                    <a4j:commandButton value="新增" execute="@this" render="tolbar,editGroup"
                                       action="#{finProjBean.add}"/>
                    <a4j:commandButton value="修改" execute="@this" render="tolbar,editGroup"
                                       action="#{finProjBean.update}"
                                       disabled="#{finProjBean.addOrUpdate or empty finProjBean.finProj}"/>
                    <a4j:commandButton value="删除" execute="@form" render="finPanel"
                                       action="#{finProjBean.delete}"
                                       disabled="#{finProjBean.addOrUpdate or empty finProjBean.finProj}"/>
                    <a4j:commandButton value="保存" execute="@form" render="finPanel"
                                       action="#{finProjBean.checkSave}"
                                       disabled="#{!finProjBean.editStatus}"/>
                    <a4j:commandButton value="取消" execute="@this" render="finPanel"
                                       action="#{finProjBean.cancel}"/>
                </rich:toolbarGroup>
            </rich:toolbar>
            <h:inputText value="#{finProjBean.finNameFilter}" size="60">
                <a4j:ajax event="blur" execute="@this" render="editTable"/>
            </h:inputText>
            <h:panelGrid columns="2" width="100%" columnClasses="top,top">
                <h:panelGroup  id="editTable">
                    <div style="max-height:400px;width:370px;overflow:auto;">
                        <rich:dataTable value="#{finProjBean.finModel}" var="pro"
                                        onrowmouseover="this.style.backgroundColor='#F1F1F1'"
                                        onrowmouseout="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                                        rowClasses="list-row-odd,list-row-even" styleClass="tableStyle">
                            <rich:column style="min-width:60px;">
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="编码"/>
                                    </h:panelGroup>
                                </f:facet>
                                <a4j:commandLink  action="#{finProjBean.selected}" execute="@this" render="tolbar,editGroup">
                                    <h:outputText value="#{pro.finCode}"/>
                                </a4j:commandLink>
                            </rich:column>
                            <rich:column filterValue="#{finProjBean.finNameFilter}"
                                         filterExpression="#{empty finProjBean.finNameFilter
                                                             or fn:contains(pro.finName,finProjBean.finNameFilter)}">
                                <f:facet name="header">
                                    <h:panelGroup>
                                        <h:outputText value="名称"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{pro.finName}"/>
                            </rich:column>
                            <rich:column style="min-width:60px;">
                                <f:facet name="header">
                                    <h:panelGroup style="white-space: nowrap">
                                        <h:outputText value="备注"/>
                                    </h:panelGroup>
                                </f:facet>
                                <h:outputText value="#{pro.memo}"/>
                            </rich:column>
                        </rich:dataTable>
                    </div>
                </h:panelGroup>
                <h:panelGroup  id="editGroup">
                    <div style="max-height:400px;width:370px;overflow:auto;">
                        <h:panelGrid columns="3" styleClass="gridStyle">
                            <h:outputText value="代码:"/>
                            <h:inputText disabled="#{!finProjBean.addOrUpdate or finProjBean.editStatus}"
                                         id="finCode" value="#{finProjBean.finProj.finCode}"/>
                            <rich:message for="finCode"/>

                            <h:outputText value="名称:"/>
                            <h:inputText disabled="#{!finProjBean.editStatus}" id="finName"
                                         value="#{finProjBean.finProj.finName}"
                                         required="true" requiredMessage="不能为空！"/>
                            <rich:message for="finName"/>

                            <h:outputText value="预算代码:"/>
                            <h:inputText disabled="#{!finProjBean.editStatus}" id="budgetCode"
                                         value="#{finProjBean.finProj.budgetCode}"/>
                            <rich:messages  for="budgetCode" globalOnly="true"/>

                            <h:outputText value="负责人:"/>
                            <h:panelGroup id="manager">                     
                                <h:inputText disabled="#{!finProjBean.editStatus}"
                                             id="managerName"
                                             value="#{finProjBean.finProj.managerName}"
                                             onclick="#{rich:component('personPanel')}.show();"/>
                                <h:inputHidden id="managerCode" value="#{finProjBean.finProj.managerCode}"
                                               required="true" requiredMessage="不能为空！"/>
                            </h:panelGroup>
                            <rich:message for="managerCode"/>

                            <h:outputText value="所属功能科目:"/>
                            <h:panelGroup id="function">
                            <h:inputText disabled="#{!finProjBean.editStatus}"
                                         id="funName" value="#{finProjBean.finProj.funName}"
                                         onclick="#{rich:component('funPanel')}.show();"/>
                            <h:inputHidden id="funCode" value="#{finProjBean.finProj.funCode}"
                                           required="true" requiredMessage="不能为空！"/>
                            </h:panelGroup>
                            <rich:message for="funCode"/>
                            
                            <h:outputText value="支出类型:"/>
                            <h:selectOneRadio disabled="#{!finProjBean.editStatus}"
                                              id="costType"
                                         value="#{finProjBean.finProj.costType}">
                                <f:selectItem itemLabel="项目" itemValue="1"/>
                                <f:selectItem itemLabel="基本" itemValue="0"/>
                            </h:selectOneRadio>
                            <rich:message for="costType"/>

                            <h:outputText value="备注:"/>
                            <h:inputText disabled="#{!finProjBean.editStatus}" id="memo" value="#{finProjBean.finProj.memo}"/>
                            <rich:message for="memo"/>
                        </h:panelGrid>
                    </div>
                </h:panelGroup>
            </h:panelGrid>
        </rich:panel>
    </h:form>

    <rich:popupPanel id="funPanel" autosized="true" width="500" height="500">
        <f:facet name="header">功能列表</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#" onclick="#{rich:component('funPanel')}.hide();
                                                 return false;">关闭</h:outputLink>
        </f:facet>
        <h:form>
            <rich:panel>
                <div style="height:400px;overflow:auto;">
                    <rich:tree value="#{functionBean.rootNode}" var="idept"
                               selectionType="ajax" toggleType="client"
                               selectionChangeListener="#{finProjBean.funTreeSelected}"
                               style="width:200px" render="tolbar,function">
                        <rich:treeNode>
                            <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                        </rich:treeNode>
                    </rich:tree>
                </div>
                <a4j:commandButton value="确定" onclick="#{rich:component('funPanel')}.hide();
                                                 return false;"/>
            </rich:panel>
        </h:form>
    </rich:popupPanel>

    <rich:popupPanel id="personPanel" autosized="true">
        <f:facet name="header">负责人</f:facet>
        <f:facet name="controls">
            <h:outputLink value="#"
                          onclick="#{rich:component('personPanel')}.hide();
                                                 return false;">关闭</h:outputLink>
        </f:facet>
        <rich:panel>
            <h:form>
                <div style="width:700px;min-height:280px;overflow:auto;">
                    <h:panelGrid columns="2" width="100%" border="0" rowClasses="treeRow" columnClasses="top,top">
                        <h:panelGroup>
                            <rich:tree value="#{departmentBean.rootNode}" var="idept"
                                       selectionType="ajax" toggleType="client"
                                       selectionChangeListener="#{personBean.treeSelected}"
                                       style="width:200px" render="tableGroup">
                                <rich:treeNode>
                                    <h:outputText value="[#{idept.data.code}]#{idept.data.name}" />
                                </rich:treeNode>
                            </rich:tree>
                        </h:panelGroup>
                        <h:panelGroup id="tableGroup">
                            <rich:dataScroller for="personinfo" execute="@this" render="tableGroup"/>
                            <div style="width: 400px;overflow:auto;">
                                <rich:dataTable  value="#{personBean.personModel}" var="person"
                                                 style="width:100%;"
                                                 rows="10"
                                                 id="personinfo">
                                    <f:facet name="header">
                                        <h:outputText value="部门人员信息" />
                                    </f:facet>
                                    <rich:column>
                                        <f:facet name="header">
                                            <h:panelGroup>
                                                <h:outputText value="人员代码"/>
                                            </h:panelGroup>
                                        </f:facet>
                                        <a4j:commandLink value="#{person.cpsn_number}"
                                                         actionListener="#{finProjBean.personSelected(person)}"
                                                         execute="@this"
                                                         render="manager"
                                                         oncomplete="#{rich:component('personPanel')}.hide();">
                                        </a4j:commandLink>
                                    </rich:column>
                                    <rich:column >
                                        <f:facet name="header">
                                            <h:panelGroup>
                                                <h:outputText value="人员姓名"/>
                                            </h:panelGroup>
                                        </f:facet>
                                        <h:outputText  value="#{person.cpsn_name}" />
                                    </rich:column>                                  
                                </rich:dataTable>
                            </div>
                        </h:panelGroup>
                    </h:panelGrid>
                </div>
            </h:form>
        </rich:panel>
    </rich:popupPanel>
</html>
